import { post,get } from '@/utils/request'
import {UserInfo,ModelType} from "@/typings/user";

export function doLogin<UserInfo>(params:ModelType) {
	return post<UserInfo>({
		url: '/auth/login',
		data: params,
	})
}

/**
 * 用户注册
 */
export function doRegist<T>(username: string, password: string,code:string) {
	return post<T>({
		url: '/auth/register',
		data: {username, password,code},
	})
}

/**
 * 重置密码
 */
export function reset<T>(username: string, password: string,code:string) {
	return post<T>({
		url: '/auth/reset/password',
		data: {username, password,code},
	})
}

/**
 * 获取邮箱验证码
 */
export function getVerificationCode(username:string) {
	return post({
		url:'/resource/email/code',
		data:{username}
	})
}


/**
 * 获取用户登录信息
 */
export function getUserInfo<UserInfo>() {
	return get<UserInfo>({
		url:'/system/user/getInfo'
	})
}

export function loginOut() {
	return post({
		url:'/auth/logout'
	})
}
